package com.koron.order.overhaul.controller;

import com.alibaba.fastjson.JSON;
import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.annocation.CasUser;
import com.koron.order.overhaul.bean.entity.OverhaulOrderReportBean;
import com.koron.order.overhaul.service.OverhaulOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author twcao
 * @title: OverhaulOrderPrepareReportController
 * @projectName GDH_EAM_V2
 * @description: 大修工单-编制大修报告
 * @date 2021/10/219:09
 */
@Slf4j
@Api(tags = "大修工单-编制大修报告")
@RestController
@RequestMapping("/overhaul/prepareReport")
public class OverhaulOrderPrepareReportController {

    @Autowired
    private OverhaulOrderService overhaulOrderService;

    @ApiOperation(value = "编制大修报告(status = 4)，保存大修报告")
    @PostMapping("/saveOrUpdate")
    public Response<Boolean> prepareReport(@CasUser @ApiIgnore EamUser user, @RequestBody OverhaulOrderReportBean report) {
        log.info("编制大修报告(status = 4)，保存大修报告，report = {}", JSON.toJSONString(report));
        return Response.ok("操作成功", ADOConnection.runTask(user.getCurrDs(), overhaulOrderService, "prepareReport", Boolean.class, report));
    }

    @ApiOperation(value = "编制大修报告(status = 4)，根据工单id详情编制大修报告详情")
    @GetMapping("/getPrepareReportByOrderId")
    public Response<OverhaulOrderReportBean> getPrepareReportByOrderId(@CasUser @ApiIgnore EamUser user, String orderId) {
        log.info("编制大修报告(status = 4)，根据工单id详情编制大修报告详情，orderId = {}", orderId);
        return Response.ok("操作成功", ADOConnection.runTask(user.getCurrDs(), overhaulOrderService, "getPrepareReportByOrderId", OverhaulOrderReportBean.class, orderId));
    }
}
